package com.hfh.test;

/**
 * @Author hfh
 * @Date 2022 09 15 10 52
 **/
public class Solution {
    public static void main(String[] args) {
        int[] arr = {2,7,11,15};
        for (int i:twoSum(arr,9)){
            System.out.print(i+" ");
        }
    }

    public static int[] twoSum(int[] nums, int target) {
        for (int i = 1;i<nums.length;i++){
            for (int j = 0;j<nums.length-i;j++){
//                System.out.println(nums[i-1]+" "+nums[j+i]);
                if((nums[i-1]+nums[j+i])==target){
                    return new int[]{i - 1, j + i};
                }
            }
            System.out.println("---");
        }
        return nums;
    }
}
